import React from 'react'
import '@/style/sider/fileOperation.scss'
import config from '../common/Common';

export default function FileOperation({item, index, createNewFile, importFiles}) {
    const IconFont = config.IconFont;
    // 新建或者导入文件
    const createOrImport = () =>{
        const obj = {
            0: createNewFile,
            1: importFiles
        }
        obj[index]()
    }
    return (
        <div className='fileOperation-piece' key={index} onClick={createOrImport}>
            <IconFont type={item.icon} className='fileOperation-icon' />
            <div className='fileOperation-title'>
                {item.title}
            </div>
        </div>
    )
}
